import pandas as pd

#===============================================================================#
#
# Table 1: Summary of Data Collection
#
#===============================================================================#

statuses = pd.read_csv('data/statuses_metadata.csv')
users = pd.read_csv('data/user_metadata.csv')

bc = users[['id_str_hash_','bot']].drop_duplicates().bot.value_counts()
tc = statuses.bot.value_counts()

table = {}
table['User Type'] = ['Social Bot','Human','Total']
table["Users: Count"] = [bc['bot'], bc['human'], bc.sum()]
table["Users: %"] = [round(bc['bot']/bc.sum()*100,1), round(bc['human']/bc.sum()*100,1), 100.0]
table["Tweets: Count"] = [tc['bot'], tc['human'], tc.sum()]
table["Tweets: %"] = [round(tc['bot']/tc.sum()*100,1), round(tc['human']/tc.sum()*100,1), 100.0]

with open('tables/table1.txt', 'w') as fout:
    print(pd.DataFrame(table)[['User Type','Tweets: Count','Tweets: %','Users: Count', 'Users: %']].to_string(index=False), file=fout)




